﻿using System;
namespace Producers.Ehr.Xtee.Riik.Ee.Producer.Ehr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="EN_OtsiAadressiAdr_query", Namespace="http://producers.ehr.xtee.riik.ee/producer/ehr", Target=typeof(ENOtsiAadressiAdrQuery))]
    public class ENOtsiAadressiAdrQuerySerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IENOtsiAadressiAdrQuery clazz;
        
        public ENOtsiAadressiAdrQuerySerializer(IENOtsiAadressiAdrQuery clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Tase1!=null) {
                Writer.WriteStartElement("tase1");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Tase1))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase2!=null) {
                Writer.WriteStartElement("tase2");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Tase2))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase3!=null) {
                Writer.WriteStartElement("tase3");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Tase3))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase4!=null) {
                Writer.WriteStartElement("tase4");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Tase4))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase5!=null) {
                Writer.WriteStartElement("tase5");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tase5))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase6!=null) {
                Writer.WriteStartElement("tase6");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tase6))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tase7!=null) {
                Writer.WriteStartElement("tase7");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tase7))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Adskood!=null) {
                Writer.WriteStartElement("adskood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Adskood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aadress!=null) {
                Writer.WriteStartElement("aadress");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "tase1")) {
                goto tase1;
            }
            else {
                if ((Reader.LocalName == "tase2")) {
                    goto tase2;
                }
                else {
                    if ((Reader.LocalName == "tase3")) {
                        goto tase3;
                    }
                    else {
                        if ((Reader.LocalName == "tase4")) {
                            goto tase4;
                        }
                        else {
                            if ((Reader.LocalName == "tase5")) {
                                goto tase5;
                            }
                            else {
                                if ((Reader.LocalName == "tase6")) {
                                    goto tase6;
                                }
                                else {
                                    if ((Reader.LocalName == "tase7")) {
                                        goto tase7;
                                    }
                                    else {
                                        if ((Reader.LocalName == "adskood")) {
                                            goto adskood;
                                        }
                                        else {
                                            if ((Reader.LocalName == "aadress")) {
                                                goto aadress;
                                            }
                                            else {
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        tase1:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase1");
            }
            clazz.Tase1 = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("tase1")).Value;
            goto START;
        tase2:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase2");
            }
            clazz.Tase2 = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("tase2")).Value;
            goto START;
        tase3:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase3");
            }
            clazz.Tase3 = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("tase3")).Value;
            goto START;
        tase4:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase4");
            }
            clazz.Tase4 = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("tase4")).Value;
            goto START;
        tase5:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase5");
            }
            clazz.Tase5 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tase5")).Value;
            goto START;
        tase6:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase6");
            }
            clazz.Tase6 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tase6")).Value;
            goto START;
        tase7:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>tase7");
            }
            clazz.Tase7 = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tase7")).Value;
            goto START;
        adskood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>adskood");
            }
            clazz.Adskood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("adskood")).Value;
            goto START;
        aadress:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>EN_OtsiAadressiAdr_query>aadress");
            }
            clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            goto START;
        }
    }
}
